<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.SmsModule.bean.*,com.SmsModule.dao.*,com.UserModule.dao.*,com.dati.dao.*,com.dianbo.dao.*,com.dati.bean.*,com.dianbo.bean.*"%>  
<%@ page import="util.*" %>
<%
	String startTime = session.getAttribute("startTime").toString();
	String endTime = session.getAttribute("endTime").toString();
	System.out.println("endTime==" + endTime);
	String content=session.getAttribute("content").toString();
	String phone=session.getAttribute("phone").toString();
	List<TbSmsSc> SmsReceiveList = (ArrayList) session.getAttribute("receiveList");
	  //---------分页
	    int currentPage=1;
	    if(request.getParameter("Page")!=null)
	    {
	    	currentPage=Integer.parseInt(request.getParameter("Page"));
	    }
	//System.out.println("size==" + SmsContentList.size());
%>

<jsp:include page="../head.jsp"></jsp:include>
<body>
<div id="pager">
<jsp:include page="../top.jsp"><jsp:param name="topCurrent" value="1" /></jsp:include>    
<jsp:include page="leftSms.jsp">
<jsp:param name="smsSendStyle" value="15" /></jsp:include> 
		<section id="container">
        <div id="crumbs">
        	短信管理 &raquo; 上传短信
        </div>
    <div id="main">
			<div class="tabs">
				<ul class="tabs-nav clearfix">
					<li>
						上传短信
					</li>
				</ul>
				<div class="tabs-panel">
				<%
			try{
		 	 String resultSM=session.getAttribute("result").toString();
			 if(!resultSM.equals("")){
				 out.println("<script>alertmess('"+resultSM+"');</script>");
				 session.removeAttribute("result");
			 }
			 }catch(Exception ex){
			 
			 }
		 	%>
				 <form action="" method="post" id="form1" name="form2">
					<table width="100%" class="datalist">
						<thead>
							<tr>
								<th colspan="9" class="tl">
												开始时间
												 <input type="text" id="startTime" size="25" name="startTime" class="Wdate" value="<%=startTime%>" readonly="readonly" onclick="WdatePicker({el:'startTime',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
												结束时间
												<input type="text" id="endTime" size="25" name="endTime" class="Wdate"  value="<%=endTime%>"   readonly="readonly"  onclick="WdatePicker({el:'endTime',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
												短信内容
												<input type="text" id="content" name="content" value="<%=content %>" />
												发送号码
												<input type="text" id="phone" name="phone" maxlength="11" value="<%=phone %>" />
												<input type="button" value="查询" onclick="searcherSM('../TbSmsServlet?method=searchRecSc')" />&nbsp;&nbsp;
												<input type="button" value="批删" onclick="deleteSmsAllSM('deleteAll','../TbSmsServlet?method=deleteAllRecSc&looksms=2&startTime=<%=startTime%>&endTime=<%=endTime%>&content=<%=content %>&phone=<%=phone %>')" />&nbsp;&nbsp;
								</th>
							</tr>
							<tr>
								<td class="tc">
									<input type="checkbox" title="全选" onClick="check_allSM('deleteAll')"/>
								</td>
								<td>
									序号
								</td>
								<td>
									短信内容
								</td>
								<td>
									接收时间
								</td>
								<td>
									手机号码
								</td>
								<td>
									类型
								</td>
								<td>
									现属类型
								</td>
								<td>
									分拣
								</td>
								<td>
									操作
								</td>
							</tr>
						</thead>
						<%
						if(SmsReceiveList!=null)
        					{
					         
					        	
					        	//---excel end
							    int i=0;  
											//--------------分页
								    					MyPagination mPage=new MyPagination();
								     					SmsReceiveList=mPage.getInitPage(SmsReceiveList,currentPage,10);
											if (SmsReceiveList != null && SmsReceiveList.size() > 0) {
											
												for (TbSmsSc smsReceiveBean : SmsReceiveList) {
												i++;
												int smsType = smsReceiveBean.getSmsType();
												String smsTypeName = "";
												String smsTypeNameT="";//已经分拣后的类型
												if(smsType==-1){
													smsTypeName="未分拣";
												}else if(smsType==0){
													smsTypeName="点播";
													String condition="receiveId="+smsReceiveBean.getSmsId();
													List<Dianbo>dianboList = new DianboDao().getDianboList("tb_qs_info","",condition);
													String dianboTypeCondition="";
													try{
														dianboTypeCondition="typeId='"+dianboList.get(0).getTypeId()+"'";
													}catch(Exception ex){
														
													}
													List<DianboType>dianboTypeList = new DianboTypeDao().getDianboList("tb_qsType_answer",dianboTypeCondition,"");
													smsTypeNameT = dianboTypeList.get(0).getTypeName();
												}else if(smsType==1){
													smsTypeName="答题";
													String condition="receiveId="+smsReceiveBean.getSmsId();
													 List<Answer> answerList = new DatiDao().getAnswerList("tb_answer","",condition);
													 if(answerList!=null&&answerList.size()>0){
														 String middleCondition = "answerMiddleId='"+answerList.get(0).getAnswerMiddleId()+"'";
														 List<DatiMiddle> middleList = new DatiDao().getDatiMiddle("tb_answer_middle","",middleCondition);
														 if(middleList!=null&&middleList.size()>0){
															 String seriseCondition = "seriseId='"+middleList.get(0).getSeriseId()+"'";
															 List<Xulie> xilieList = new DatiTypeDao().getXulieByTypeId("tb_serise","",seriseCondition);
																 if(xilieList!=null&&xilieList.size()>0){
																	 String typeCondition="answerTypeId='"+xilieList.get(0).getAnswerTypeId()+"'";
																	 List<DatiType> datiType= new DatiTypeDao().getAllDaTiType("tb_answer_type","",typeCondition);
																	 if(datiType!=null&&datiType.size()>0){
																		 smsTypeNameT = datiType.get(0).getTypeName();
																	 }
																 
																	 
																 }
															 
														 }
														 
													 }
												}
						%>
						<tr>
							<td class="tc">
								<input name="deleteAll" id = "deleteAll" type="checkbox" value="<%=smsReceiveBean.getSmsId()%>"/>
							</td>
							<script type="text/javascript">
							$(function(){
				 				$('#demo-basic<%=i%>').poshytip();
							
				   			})
				  			 </script>
				  			 <td><%=((10*(currentPage-1))+i) %></td>
							<td><a id="demo-basic<%=i%>" title="<%=smsReceiveBean.getSmscontent()%>" href="#"><%=new UtilDAO().sub_String(smsReceiveBean.getSmscontent())%></a></td>
							<td><%=smsReceiveBean.getCreateTime()%></td>
							<td><%=smsReceiveBean.getSendPhone() %></td>
							<td><%=smsTypeName %></td>
							<td><%=smsTypeNameT %></td>
							<td><a style="cursor:hand" onclick="fenjian('./TbSmsServlet?method=fenjian&smsId=<%=smsReceiveBean.getSmsId() %>&sendPhone=<%=smsReceiveBean.getSendPhone() %>&smsType=<%=smsReceiveBean.getSmsType() %>&endTime=<%=endTime %>&startTime=<%=startTime %>&content=<%=content %>&phone=<%=phone %>&num=<%=new Random().nextInt(10000000) %>')">分拣</a></td>
							<td class="tc">
								<a title="删除该短信" class="duanyu_del" style="cursor:hand" onClick="deleteOneSM('../TbSmsServlet?method=deleteOneRecSc&smsId=<%=smsReceiveBean.getSmsId() %>')">删除</a>
							</td>
						</tr> 
						<%
							}
							}
							%>
											<%=mPage.printCtrl("SmsModule/SmsReceiveList.jsp",currentPage,"&startTime="+startTime+"&endTime="+endTime+"&content="+content+"&phone="+phone) %>
											<%
											}
						%>
						
					</table>
					
				</form>
				</div>
		</div>
		</section>
		  <jsp:include page="../foot.jsp"></jsp:include>
	</body>
</html>
